package com.zhida.smartcontrol.pagehome.hdimmerdialog;

import com.zhida.smartcontrol.common.Api;
import com.zhida.smartcontrol.common.Const;
import com.zhida.smartcontrol.common.bean.LampBean;
import com.zhida.smartcontrol.common.bean.LampSwitchBean;
import com.zhida.smartcontrol.knet.KalleCallBack;
import com.zhida.smartcontrol.mvp.BasePresenterImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HDimmerDialogPresenter extends BasePresenterImpl<HDimmerDialogContract.View> implements HDimmerDialogContract.Presenter {

    @Override
    public void plcBrightness(LampBean bean, String type) {
        List<String> list = new ArrayList<>();
        list.add(bean.getId());

        Map<String, Object> params = new HashMap<>();
        params.put("idList", list);
        params.put("type", type); //1：100%         2：75%       3：50%       4：25%       0：0%
        mKalleCenter.postJson(Api.ADJUST_PLC_BRIGHTNESSES, params, true, new KalleCallBack() {
            @Override
            public void onSuccess(String result, String msg) {
                mView.showMsg(msg);
                mView.onSuccess();
            }

            @Override
            public void onFailed(String msg) {
                if (null != mView)
                    mView.showMsg(msg);
            }
        });
    }

    @Override
    public void nbBrightness(List<String> code, String type, String value) {

        Map<String, Object> params = new HashMap<>();
        params.put("codeList", code);
        params.put("type", type); // 1：主灯 2：辅灯 3：主辅灯全选  ""：NB 单灯
        params.put("value", value); //1：100% 2：75% 3：50% 4：25% 0：0%
        mKalleCenter.postJson(Api.ADJUST_NB_BRIGHTNESSES, params, true, new KalleCallBack() {
            @Override
            public void onSuccess(String result, String msg) {
                mView.showMsg(msg);
                mView.onSuccess();
            }

            @Override
            public void onFailed(String msg) {
                if (null != mView)
                    mView.showMsg(msg);
            }
        });
    }

}
